package com.jiezheng.huinong.biz;

import com.jiezheng.huinong.constant.LoginFailType;
import com.jiezheng.huinong.dao.UserManageDAOImpl;
import com.jiezheng.huinong.model.UserInfo;


public class UserManage {
	
	/**
	 * 用户登录验证
	 * @param user
	 * @return
	 */
	public static LoginFailType checkUser(UserInfo user) {
		UserInfo userIn = (new UserManageDAOImpl()).getUserByLoginId(user.getLoginId());
		if(userIn == null || userIn.getLoginId().isEmpty())
		{
			return LoginFailType.NO_USER_ACCOUNT;
		}
		
		if(userIn.getPassword() == null || !userIn.getPassword().equals(user.getPassword()))
		{
			return LoginFailType.PASSWORD_ERROR;
		}
		return LoginFailType.LOGIN_SUCCESS;
	}
	
}
